/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.WebIDE.ejb.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

/**
 *
 * @author huy
 */
@Entity
@Table(name = "groups_resources")
@NamedQueries({@NamedQuery(name = "GroupsResources.findAll", query = "SELECT g FROM GroupsResources g"), @NamedQuery(name = "GroupsResources.findByGroupName", query = "SELECT g FROM GroupsResources g WHERE g.groupsResourcesPK.groupName = :groupName"), @NamedQuery(name = "GroupsResources.findByResourceId", query = "SELECT g FROM GroupsResources g WHERE g.groupsResourcesPK.resourceId = :resourceId"), @NamedQuery(name = "GroupsResources.findByC", query = "SELECT g FROM GroupsResources g WHERE g.c = :c"), @NamedQuery(name = "GroupsResources.findByR", query = "SELECT g FROM GroupsResources g WHERE g.r = :r"), @NamedQuery(name = "GroupsResources.findByU", query = "SELECT g FROM GroupsResources g WHERE g.u = :u"), @NamedQuery(name = "GroupsResources.findByD", query = "SELECT g FROM GroupsResources g WHERE g.d = :d")})
public class GroupsResources implements Serializable {
    private static final long serialVersionUID = 1L;
    @EmbeddedId
    protected GroupsResourcesPK groupsResourcesPK;
    @Basic(optional = false)
    @Column(name = "c")
    private boolean c;
    @Basic(optional = false)
    @Column(name = "r")
    private boolean r;
    @Basic(optional = false)
    @Column(name = "u")
    private boolean u;
    @Basic(optional = false)
    @Column(name = "d")
    private boolean d;
    @JoinColumn(name = "group_name", referencedColumnName = "group_name", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Groups groups;
    @JoinColumn(name = "resource_id", referencedColumnName = "id", insertable = false, updatable = false)
    @ManyToOne(optional = false, fetch = FetchType.EAGER)
    private Resources resources;

    public GroupsResources() {
    }

    public GroupsResources(GroupsResourcesPK groupsResourcesPK) {
        this.groupsResourcesPK = groupsResourcesPK;
    }

    public GroupsResources(GroupsResourcesPK groupsResourcesPK, boolean c, boolean r, boolean u, boolean d) {
        this.groupsResourcesPK = groupsResourcesPK;
        this.c = c;
        this.r = r;
        this.u = u;
        this.d = d;
    }

    public GroupsResources(String groupName, int resourceId) {
        this.groupsResourcesPK = new GroupsResourcesPK(groupName, resourceId);
    }

    public GroupsResourcesPK getGroupsResourcesPK() {
        return groupsResourcesPK;
    }

    public void setGroupsResourcesPK(GroupsResourcesPK groupsResourcesPK) {
        this.groupsResourcesPK = groupsResourcesPK;
    }

    public boolean getC() {
        return c;
    }

    public void setC(boolean c) {
        this.c = c;
    }

    public boolean getR() {
        return r;
    }

    public void setR(boolean r) {
        this.r = r;
    }

    public boolean getU() {
        return u;
    }

    public void setU(boolean u) {
        this.u = u;
    }

    public boolean getD() {
        return d;
    }

    public void setD(boolean d) {
        this.d = d;
    }

    public Groups getGroups() {
        return groups;
    }

    public void setGroups(Groups groups) {
        this.groups = groups;
    }

    public Resources getResources() {
        return resources;
    }

    public void setResources(Resources resources) {
        this.resources = resources;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (groupsResourcesPK != null ? groupsResourcesPK.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof GroupsResources)) {
            return false;
        }
        GroupsResources other = (GroupsResources) object;
        if ((this.groupsResourcesPK == null && other.groupsResourcesPK != null) || (this.groupsResourcesPK != null && !this.groupsResourcesPK.equals(other.groupsResourcesPK))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.WebIDE.ejb.entities.GroupsResources[groupsResourcesPK=" + groupsResourcesPK + "]";
    }

}
